<template>

	<view>
		<bg-video></bg-video>
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block class="text-white" slot="content">奖励详细</block>
		</cu-custom>
		<view>
			<view class="flex bg-white justify-between shadow padding">
				<view class=" flex justify-center flex-direction align-center">
					<view class="cu-avatar xl round" :style="'background-image:url('+ajiaolian.cover+');'"></view>
					<view class="padding-sm">{{ajiaolian.jlname}}</view>
				</view>
				<view class=" text-xl  padding">
					<view>{{ahylx.hlname}}</view>
				</view>
			</view>
			<view class="bg-white padding-sm flex justify-between">
				<text>实付金额：</text>
				<text class="text-red">￥{{hyjl.amount / 100}}</text>
			</view>
			<view class="bg-white padding-sm flex justify-between">
				<text>余额付金额：</text>
				<text class="text-red">￥{{hyjl.yezfje / 100}}</text>
			</view>
			<view class="bg-white padding-sm flex justify-between">
				<text>合计金额：</text>
				<text class="text-red">￥{{(hyjl.amount + hyjl.yezfje) / 100}}</text>
			</view>
			<view class="bg-white padding-sm flex justify-between">
				<text>支付状态：</text>
				<text v-if="hyjl.amount > 0 && hyjl.yezfje == 0 && hyjl.pflg" class="text-blue">全额已付</text>
				<text v-if="hyjl.amount > 0 && hyjl.yezfje == 0 && !hyjl.pflg" class="text-red">全额未付</text>
				<text v-if="hyjl.amount > 0 && hyjl.yezfje > 0 && hyjl.pflg" class="text-green">部分已付</text>
				<text v-if="hyjl.amount > 0 && hyjl.yezfje > 0 && !hyjl.pflg" class="text-red">部分未付</text>
				<text v-if="hyjl.amount == 0 && hyjl.yezfje > 0 && !hyjl.pflg" class="text-green">全余额付</text>
			</view>
			<view class="bg-white padding-sm flex justify-between">
				<text>会员状态：</text>
				<text v-if="hyjl.stu == 'U'">未开始</text>
				<text v-if="hyjl.stu == 'R'">已生效</text>
				<text v-if="hyjl.stu == 'F'">已结束</text>
			</view>
			<view class="bg-white padding-sm flex justify-between">
				<text>购买时间：</text>
				<text class="">{{hyjl.cd}}</text>
			</view>
			<view v-if="hyjl.sd" class="bg-white padding-sm flex justify-between">
				<text>开始时间：</text>
				<text class="">{{hyjl.sd}}</text>
			</view>
			<view v-if="hyjl.ed" class="bg-white padding-sm flex justify-between">
				<text>结束时间：</text>
				<text class="">{{hyjl.ed}}</text>
			</view>
			<view  class="bg-white padding-sm flex justify-between">
				<text>周期：</text>
				<text class="">{{hyjl.zq}}</text>
			</view>
			<view  class="bg-white padding-sm flex justify-between">
				<text>剩余次数：</text>
				<text class="">{{hyjl.sycs}}</text>
			</view>
			<view  class="bg-white padding-sm flex justify-between">
				<text>退款状态：</text>
				<text v-if="hyjl.tkflg == 'U'">未退款</text>
				<text v-if="hyjl.tkflg == 'R'">已申退</text>
				<text v-if="hyjl.tkflg == 'J'">已退还</text>
			</view>
			
		</view>

		<view v-if="hyjl.tkflg == 'U' && hyjl.stu == 'U'" class="padding">
			<button class="cu-btn block bg-blue lg" @tap="goRefund">退款</button>
		</view>

	</view>
</template>

<script>
	export default {
		data: function() {
			return {
				hyjl: {},
				ahylx: {},
				ajiaolian: {},
				client: {}
			};
		},
		onShareAppMessage: function(){
			return {
				title: this.store.state.title,
				path: '/pages/first?id='+this.store.state.client.clientid
			}
		},
		onLoad: function(option) {
			this.hyjl.hyjlid = option.hyjlid;
			this.loadHy();
		},
		methods: {
			loadHy: function() {
				this.http.get({
					url: "/client/hyjl/info?hyjlid=" + this.hyjl.hyjlid,
				}).then(data => {
					console.log(data);
					this.hyjl = data.ahyjl;
					this.ahylx = data.ahylx;
					this.ajiaolian = data.ajiaolian;
					this.client = data.client;
				})
			},
			goRefund: function() {
				uni.showModal({
					title: '提示',
					content: '请确认是否退款',
					success: (res) => {
						if (res.confirm) {
							this.http.put({
								url: "/client/hyjl/refund?hyjlid=" + this.hyjl.hyjlid
							}).then(data => {
								this.hyjl = data.ahyjl;
							});

						}
					}
				})
			}
		}
	}
</script>

<style>
</style>